function [] = fp_mult_tb()
    %Q = [0   1 0 0 0 0 0 0 0   0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0];
    %q = (-1)^Q(1)*(1+binfrac2dec(Q(10:32)))*2^(binint2dec(Q(2:9))-127);

    %00 11011101001011110001101 101010000000000000000000
    %01 00100000000000000000000 000000000000000000000000
    

    
    
    % 1*-1=-1 
    A = [0   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 1
    B = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    E = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    P = fp_mult(A,B);
    assert(A,B,P,E);
    
    % -1*1=-1 
    A = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    B = [0   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 1
    E = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    P = fp_mult(A,B);
    assert(A,B,P,E);

    % -1*-1=1 
    A = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    B = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % -1
    E = [1   0 1 1 1 1 1 1 1   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 1
    P = fp_mult(A,B);
    assert(A,B,P,E);
    
    % 0.001*54.0=0.054
    A = [0   0 1 1 1 0 1 0 1   0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1]; % 0.001
    B = [0   1 0 0 0 0 1 0 0   1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 54
    E = [0   0 1 1 1 1 0 1 0   1 0 1 1 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 0 1 1]; % 0.054
    P = fp_mult(A,B);
    assert(A,B,P,E);

    % 6*6=36
    A = [0   1 0 0 0 0 0 0 1   1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 6
    B = [0   1 0 0 0 0 0 0 1   1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 6
    E = [0   1 0 0 0 0 1 0 0   0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 36
    P = fp_mult(A,B);
    assert(A,B,P,E);
    
    % 17*25=425
    A = [0   1 0 0 0 0 0 1 1   0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 17
    B = [0   1 0 0 0 0 0 1 1   1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 25
    E = [0   1 0 0 0 0 1 1 1   1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 425
    P = fp_mult(A,B);
    assert(A,B,P,E);
    
    % 503.0012*23.9002=1.202182928024000e+004
    A = [0   1 0 0 0 0 1 1 1   1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1]; % 503.0012
    B = [0   1 0 0 0 0 0 1 1   0 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 1 1 0 0]; % 23.9002
    E = [0   1 0 0 0 1 1 0 0   0 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0]; % 1.202182928024000e+004
    P = fp_mult(A,B);
    assert(A,B,P,E);

    % -503.0012*23.9002=1.202182928024000e+004
    A = [1   1 0 0 0 0 1 1 1   1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1]; % 503.0012
    B = [0   1 0 0 0 0 0 1 1   0 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 1 1 0 0]; % 23.9002
    E = [1   1 0 0 0 1 1 0 0   0 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0]; % 1.202182928024000e+004
    P = fp_mult(A,B);
    assert(A,B,P,E);

    % 123412341234.12341234*5757846041919488=7.105892519127363e+026
    A = [0   1 0 1 0 0 0 1 1   1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1 1 1]; % 123412341234.12341234
    B = [0   1 0 1 1 0 0 1 1   0 1 0 0 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1 1 0 0 0]; % 5757846041919488
    E = [0   1 1 0 1 1 0 0 0   0 0 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0]; % 7.105892519127363e+026
    P = fp_mult(A,B);
    assert(A,B,P,E);
end

function assert(A,B,P,E)
    A_dec = fp2dec(A);
    B_dec = fp2dec(B);
    P_dec = fp2dec(P);
    P_ = fp2dec(E);
    if P == E
        fprintf('\tYES: %.32f\t*\t%.32f\t=\t\t%.32f\n',A_dec,B_dec,P_dec);
    else
        fprintf('\tNO : %.45f*%.45f=%.45f, correct is: %.45f\n\t%s should be\n\t%s\n',A_dec,B_dec,P_dec,P_,mat2str(P),mat2str(E));
    end
end

